package controllers

import (
	"ginDev/frans"
	"ginDev/models"
	"github.com/gin-gonic/gin"
)

type IndexController struct {
	*frans.GormAdapter
}

func NewIndexController() *IndexController {
	return &IndexController{}
}

/*func (this *IndexController) Route(frans *frans.Frans) {
	frans.Handle("GET", "/", this.Index())
}

func (this *IndexController) Index() gin.HandlerFunc {
	return func(context *gin.Context) {
		context.JSON(http.StatusOK, gin.H{
			"data": "index",
		})
	}
}*/

func (this *IndexController) Route(frans *frans.Frans) {
	frans.Handle("GET", "/", this.Index)
}

func (this *IndexController) Index(ctx *gin.Context) frans.Model {
	//return "index"

	user := models.UserModel{}
	this.Table("users").Where("id=?", 1).Find(&user)

	return &user
}
